﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
//using System.Drawing;
using System.Linq;
using System.Text;
//using System.Windows.Forms;

using System.Xml;
using System.Xml.XPath;

namespace QA_System
{
    sealed class SentenceObjectControl
    {
        static Stack<sentence_tagger> sentence_stack = new Stack<sentence_tagger>();
        static Stack<sentence_tagger> outsentence_stack = new Stack<sentence_tagger>();
        static private bool instance_flag = false;

        public SentenceObjectControl()
       {
           if (!instance_flag)
           {
               instance_flag = true;
           }
           else throw new Exception("Only one instanc allowed");
       }

        static private sentence_tagger lastfound = null;

        static private string maintitle = "";

        static public void RecordSentence(sentence_tagger senten)
        {
            try
            {
                if (senten != null)
                {
                    sentence_stack.Push(senten);
                }
            }
            catch (OutOfMemoryException ex)
            {
                throw ex;
            }
        }

        static public sentence_tagger GetSentence()
        {
            try
            {
                sentence_tagger sen = null;
                if(sentence_stack.Count>0)
                {
                    sen = sentence_stack.Pop();
                    outsentence_stack.Push(sen);
                }
                return sen;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        static void Clear()
        {
            sentence_stack.Clear();
            outsentence_stack.Clear();
        }

        static public void FinishGetSentence()
        {
            try
            {
                sentence_tagger sen = null;
                while (outsentence_stack.Count > 0)
                {
                    sen = outsentence_stack.Pop();
                    sentence_stack.Push(sen);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public sentence_tagger LastFoundSentence
        {
            set { lastfound = value; }

            get { return lastfound; }
        }

        public string Maintite
        {
            set { maintitle = value; }

            get { return maintitle; }
        }
       
    }
}
